from time import sleep
from tkinter import ttk, scrolledtext
from tkinter import *
from ModeType.Base import BaseOutput

# 打字机模式

class TypewriterResult(BaseOutput):
    def __init__(self):
        super().__init__()
        self.isPressEnter = False

    def createConfig(self, root):
        self.commonConfig(root)
        box = ttk.LabelFrame(root, text='打字机模式配置')
        box.pack(padx=10, pady=10)

        row = 0
        ttk.Label(box, text='内容').grid(row=row, column=0)
        self.strtemp = scrolledtext.ScrolledText(box, height=10)
        self.strtemp.grid(row=row, column=1)
        self.strtemp.insert(INSERT, '请输入内容')

        return box

    def run(self):
        speed = self.get_speed()
        content = self.get_strtemp()
        for item in content:
            self.keyResultContent(item)
            sleep(speed)
